import java.util.Arrays;

class MyStock{
    int[] elem;
    int len;

    MyStock(){
        this.elem = new int[10];
    }

    public void push (int val){
        if (isfull()){
            elem=Arrays.copyOf(elem,2*elem.length);
        }
            elem[len++]=val;
    }

    public int pop (){
        if (elem.length==0){
            System.out.println("失败！栈已经空了");
        }

        return elem[--len];
    }

    public int size(){
        return elem.length;
    }

    public boolean isfull(){
        if (elem.length==len){
            return true;
        }
        return false;
    }
}

public class extT {
    public static void main(String[] args) {
        MyStock a = new MyStock();
        a.push(1);
        a.push(2);
        a.push(3);
        a.push(4);
        System.out.println(a.pop());
        System.out.println(a.pop());
        System.out.println(a.len);
    }
}
